<?php
/**
 * Checkrole.php
 * Created by RisingSun
 * User: MarkSpace 
 * Create on 2023/10/10 15:16
 */
namespace common;

class Checkrole
{

    /** @var User $user 用户信息 */
    private $user;

    /**
    * 验证指定用户是否有访问权限
    * @param string|array $modelid
    * @return bool
    */
    public static function module($user)
    {
      
      try
      {
          return Role::getInstance()->module($user);
      } catch (\Exception $e) {
          return false;
      }
    }

    /**
    * 验证指定用户是否有访问权限
    * @param string|array $modelid
    * @return bool
    */
    public static function getRules($user)
    {
      try
      {
          return Role::getInstance()->getRules($user);
      } catch (\Exception $e) {
          return $e;
      }
    }

    /**
    * 验证指定用户是否有访问权限
    * @param string|array $modelid
    * @return bool
    */
    public static function checkRolePer($module_id,$key,$user)
    {
      
      try
      {
          $data=Role::getInstance()->checkRolePer($module_id, $user);
          if(isset($data[$key])){
              return $data['code'].$data[$key];
          }else{
              return false;
          }
      } catch (\Exception $e) {
          return false;
      }
    }

    /**
    * 获取角色所有权限
    * @param string|array $modelid
    * @return bool
    */
    public static function getRolePerAll($user)
    {
      try
      {
          return Role::getInstance()->getRolePerAll($user);        
      } catch (\Exception $e) {
          return false;
      }
    }

}